<!DOCTYPE HTML>
<html lang="zh-CN">




<head>
    <meta charset="utf-8">
    <meta name="keywords" content="Centos虚拟机, 深度学习 故障诊断 Java">
    <meta name="description" content="河海大学 | 计算机与信息学院 | 信号与信息处理">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>Centos虚拟机 | 世庆的博客</title>
    <link rel="icon" type="image/png" href="/shiqing/favicon.png">

    <link rel="stylesheet" type="text/css" href="/shiqing/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/shiqing/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/shiqing/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/shiqing/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/shiqing/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/shiqing/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/shiqing/css/my.css">

    <script src="/shiqing/libs/jquery/jquery.min.js"></script>

    <script src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8"></script>
<meta name="generator" content="Hexo 6.3.0"></head>




    <body>
        <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/shiqing/" class="waves-effect waves-light">
                    
                    <img src="/shiqing/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">世庆的博客</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shiqing/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shiqing/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shiqing/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shiqing/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shiqing/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shiqing/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/shiqing/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/shiqing/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">世庆的博客</div>
        <div class="logo-desc">
            
            河海大学 | 计算机与信息学院 | 信号与信息处理
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/shiqing/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shiqing/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shiqing/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shiqing/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shiqing/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shiqing/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/shiqing/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/sqtian-hhu/" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/sqtian-hhu/" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

        



<div class="bg-cover pd-header post-cover" style="background-image: url('/shiqing/medias/featureimages/17.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">Centos虚拟机</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/shiqing/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        padding: 35px 0 15px 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        padding-bottom: 30px;
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/shiqing/tags/Linux/">
                                <span class="chip bg-color">Linux</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2022-12-02
                </div>
                

                

                

                

                
            </div>
        </div>
        <hr class="clearfix">

        
        <!-- 是否加载使用自带的 prismjs. -->
        <link rel="stylesheet" href="/shiqing/libs/prism/prism.css">
        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <h1 id="mac安装虚拟机"><a href="#mac安装虚拟机" class="headerlink" title="mac安装虚拟机"></a>mac安装虚拟机</h1><pre><code>安装软件：Parallers Desktop
硬盘已损坏无法打开的问题：xattr -r -d com.apple.quarantine APP拖入终端
</code></pre>
<h2 id="安装centos7"><a href="#安装centos7" class="headerlink" title="安装centos7"></a>安装centos7</h2><ol>
<li>进入系统后选择sudo方式安装parallers tools，可以和虚拟机共享本地磁盘。</li>
<li>虚拟机终端输入 sudo passwd 设置root密码，之后可通过su root进入root用户</li>
</ol>
<h2 id="安装jdk"><a href="#安装jdk" class="headerlink" title="安装jdk"></a>安装jdk</h2><pre><code>   先卸载自带java，自带的不全，没有javac
</code></pre>
<ol>
<li>检查系统是否自带了jdk：java -version</li>
<li>检测jdk安装包：rpm -qa ｜ grep java</li>
<li>卸载openjdk：yum remove <em>openjdk</em></li>
<li>再次查看卸载情况：rpm -qa ｜ grep java</li>
<li>安装新的jdk，下载tar.gz包，解压到目标路径：tar -zxvf jdk.tar.gz -C &#x2F;usr&#x2F;lib&#x2F;jvm</li>
<li>设置环境变量：vim &#x2F;etc&#x2F;profile<br>   添加<br> <!--    
 export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_121
 export JRE_HOME=${JAVA_HOME}/jre
 export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
 export  PATH=${JAVA_HOME}/bin:$PATH 
 -->source &#x2F;etc&#x2F;profile<br> 执行profile：</li>
<li>解决每次新开终端都要source：cd回到主路径，vim .bashrc<br> 在最后加一行：source &#x2F;etc&#x2F;profile</li>
<li>查看java安装是否成功：java -version javac -version</li>
</ol>
<h1 id="安装mysql"><a href="#安装mysql" class="headerlink" title="安装mysql"></a>安装mysql</h1><pre><code>   先卸载自带的
</code></pre>
<ol>
<li>查看是否已经安装了mariadb：yum list installed | grep mariadb</li>
<li>卸载查到的名字：yum –y remove xxxx<br>   *如果卸载不成功，需要去掉参数-y，手动确认卸载。</li>
<li>上传mysql安装包到&#x2F;opt下</li>
<li>解压mysql安装包到目录&#x2F;opt：tar -zxvf</li>
<li>修改解压后的根目录名：mv </li>
<li>进到mysql目录下创建数据文件夹data：mkdir data</li>
<li>创建用来执行mysqld命令的Linux用户<br>   创建组：groupadd mysql<br>   创建用户，并指定组：useradd -g mysql mysql</li>
<li>初始化mysql，进入到bin目录下执行：.&#x2F;mysqld –initialize –user&#x3D;mysql –datadir&#x3D;&#x2F;opt&#x2F;mysql-5.7.18&#x2F;data –basedir&#x3D;&#x2F;opt&#x2F;mysql-5.7.18 ，生成初始密码，保存下来</li>
<li>启用安全功能，在bin目录下执行：.&#x2F;mysql_ssl_rsa_setup –datadir&#x3D;&#x2F;opt&#x2F;mysql-5.7.18&#x2F;data</li>
<li>修改mysql安装目录权限，进到上级目录（&#x2F;opt），执行：chown -R mysql:mysql &#x2F;opt&#x2F;mysql-5.7.18&#x2F;<br>  chmod 777 &#x2F;opt&#x2F;mysql-5.7.18&#x2F;</li>
<li>启动mysql，mysql-5.7.18&#x2F;bin目录下执行命令：.&#x2F;mysqld_safe &amp;<br>确认msyql是否启动，查看进程 ，使用ps -ef | grep mysql</li>
<li>客户端登录mysql，进入bin目录下执行命令：.&#x2F;mysql -uroot -p ，输入初始化生成的密码</li>
<li>修改root密码，执行sql语句 show databases; ，提示更改密码：alter user ‘root‘@’localhost’ identified by ‘密码’;</li>
<li>授权远程访问：grant all privileges on <em>.</em> to root@’%’ identified by ‘密码’;</li>
<li>更新权限信息，执行flush刷新权限：flush privileges;</li>
<li>exit推出mysql，关闭防火墙：systemctl stop firewalld</li>
<li>关闭mysql服务，mysql-5.7.18&#x2F;bin目录下执行：.&#x2F;mysqladmin -uroot -p shutdown 输入密码关闭</li>
<li>配置环境变量：vi etc&#x2F;profile<br>    export PATH&#x3D;$PATH:&#x2F;opt&#x2F;mysql-5.7.18&#x2F;bin</li>
</ol>
<h1 id="配置SMTP服务"><a href="#配置SMTP服务" class="headerlink" title="配置SMTP服务"></a>配置SMTP服务</h1><h2 id="基于sendmail的方式（不推荐）"><a href="#基于sendmail的方式（不推荐）" class="headerlink" title="基于sendmail的方式（不推荐）"></a>基于sendmail的方式（不推荐）</h2><ol>
<li>关闭防火墙：systemctl stop firewalld</li>
<li>安装sendmail<br>  yum install -y sendmail<br>  yum install -y sendmail-cf</li>
<li>启动saslauthd服务进行SMTP验证<br> service saslauthd start<br> service sendmail start</li>
<li>设置Sendmail服务的网络访问权限（如果是直接本机调用，可以不用操作，采用默认的127.0.0.1。不过最后还是改成0.0.0.0），将127.0.0.1改为0.0.0.0，意思是任何主机都可以访问Sendmail服务。<br> vim &#x2F;etc&#x2F;mail&#x2F;sendmail.mc<pre class="line-numbers language-markdown" data-language="markdown"><code class="language-markdown">DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre></li>
<li>生成配置文件，Sendmail的配置文件由m4来生成，m4工具在sendmail-cf包中。如果系统无法识别m4命令，说明sendmail-cf软件包没有安装<br> m4 &#x2F;etc&#x2F;mail&#x2F;sendmail.mc &gt; &#x2F;etc&#x2F;mail&#x2F;sendmail.cf</li>
<li>启动服务（如果发现sendmail dead but subsys locked，那就执行”service postfix status”查看postfix是否默认开启了，如果开启的话，就关闭postfix，然后再启动或重启sendmail服务即可。）<br> service sendmail start<br> service saslauthd restart<br> 将服务加入自启行列<br> chkconfig sendmail on<br> chkconfig saslauthd on</li>
<li>修改配置文件</li>
<li>vim &#x2F;etc&#x2F;hosts<pre class="line-numbers language-markdown" data-language="markdown"><code class="language-markdown">127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4  
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6  
  
ip xxx.com<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span></span></code></pre>
<pre><code>9. 测试发送
</code></pre>
 安装mailx<br> yum -y install mailx<br> echo “content” | mail -s “title” <a href="mailto:&#x78;&#x78;&#x78;&#x78;&#120;&#x78;&#120;&#x40;&#49;&#54;&#51;&#x2e;&#x63;&#111;&#109;">&#x78;&#x78;&#x78;&#x78;&#120;&#x78;&#120;&#x40;&#49;&#54;&#51;&#x2e;&#x63;&#111;&#109;</a><br> tail -f &#x2F;var&#x2F;log&#x2F;maillog 查看日志，成功提示 250 Ok</li>
</ol>
<h2 id="基于postfix配置smtp服务（推荐）"><a href="#基于postfix配置smtp服务（推荐）" class="headerlink" title="基于postfix配置smtp服务（推荐）"></a>基于postfix配置smtp服务（推荐）</h2><ol>
<li>关闭防火墙   <pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">systemctl stop firewalld
systemctl disable firewalld //开机关闭<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre></li>
<li>如果装了sendmail的话，先卸载了。<pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">yum remove <span class="token function">sendmail</span><span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre></li>
<li>安装postfix<br> 检查postfix是否已安装：<pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token function">rpm</span> <span class="token parameter variable">-qa</span> <span class="token operator">|</span> <span class="token function">grep</span> postfix<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
 如果已安装则会有版本显示<br> 如果没安装就运行该命令：<pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">yum <span class="token parameter variable">-y</span> <span class="token function">install</span> postfix<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre></li>
<li>安装sasldb、saslauthd<br> 用来提供<a target="_blank" rel="noopener" href="https://so.csdn.net/so/search?q=smtp&spm=1001.2101.3001.7020">smtp</a>的虚拟账户和密码服务 sasldb2包含在saslauthd当中  <pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">yum <span class="token parameter variable">-y</span> <span class="token function">install</span> cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain cyrus-sasl-devel<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre></li>
<li>Postfix配置并启用smtp<pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token function">vim</span> /etc/postfix/main.cf<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
   <pre class="line-numbers language-markup" data-language="markup"><code class="language-markup">#修改以下配置
#邮件服务器的主机名
myhostname=mail.xxx.com
#邮件域
mydomain=xxx.com
#往外发邮件的邮件域
myorigin=$mydomain
inet_interfaces=all
#监听的网卡
inet_protocols=all
#服务的对象
mydestination = myhostname,localhost.myhostname,localhost.myhostname,localhost.mydomain, localhost
#指定信任网段类型
mynetworks_style = host 
#修改可接收邮件的主机名和域名，可被中继的主机192.168.43.0为自己定义的网段
mynetworks = 192.168.43.0/24, 127.0.0.0/8 
#指定允许中转邮件的域名
relay_domains = $mydestination 
home_mailbox=Maildir/#邮件存放的目录
#新添加以下配置
#--------自定义（下面可以复制粘贴到文件最后面，用于设置服务器验为主等）
#规定邮件最大尺寸为10M
message_size_limit=10485760
#规定收件箱最大容量为1G
mailbox_size_limit=1073741824<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
 修改保存后检查配置文件是否有错<pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">postfix check
systemctl restart postfix.service
systemctl <span class="token builtin class-name">enable</span> postfix.service     <span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></code></pre>
 使用 <code>postconf</code> 指令即可查看你的所有Postfix配置</li>
<li>编辑sasl2配置<br> 32位系统的在 <code>/usr/lib/sasl2/smtpd.conf</code> 64位的在 <code>/etc/sasl2/smtpd.conf</code>   <pre class="line-numbers language-yaml" data-language="yaml"><code class="language-yaml"><span class="token key atrule">pwcheck_method</span><span class="token punctuation">:</span> auxprop
<span class="token key atrule">auxprop_plugin</span><span class="token punctuation">:</span> sasldb
<span class="token key atrule">mech_list</span><span class="token punctuation">:</span> plain login CRAM<span class="token punctuation">-</span>MD5 DIGEST<span class="token punctuation">-</span>MD5<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></code></pre></li>
<li>修改 cyrus-sasl主配置文件<br> 定义认证方式为sasldb2<pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token function">vi</span> /etc/sysconfig/saslauthd<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
   <pre class="line-numbers language-yaml" data-language="yaml"><code class="language-yaml">        <span class="token comment">#MECH=shadow</span>
        FLAGS=sasldb
```          
   8. 更改默认MTA为Postfix
```bash
        alternatives <span class="token punctuation">-</span><span class="token punctuation">-</span>config mta<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
 选择protfix对应的编号</li>
<li>创建SMTP账号   <pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">saslpasswd2 <span class="token parameter variable">-c</span>   <span class="token parameter variable">-u</span> <span class="token variable"><span class="token variable">`</span>postconf <span class="token parameter variable">-h</span> mydomain<span class="token variable">`</span></span> <span class="token builtin class-name">test</span><span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
 上面的 postconf -h mydomain 是指从postfix的配置里获取账户的后缀(@之后)<br> 下面的即为制定了@后的后缀<br> 最后的test即为创建的账号头部 最后的账号为(<a href="mailto:&#116;&#101;&#x73;&#x74;&#x40;&#120;&#x78;&#x78;&#46;&#x63;&#x6f;&#x6d;">&#116;&#101;&#x73;&#x74;&#x40;&#120;&#x78;&#x78;&#46;&#x63;&#x6f;&#x6d;</a>)<br> 回车后输入两次密码即可创建账号<br> 使用 sasldblistusers2 指令即可查看所有的用户</li>
<li>发送邮件<br>修改完成后运行postifx：service postfix start<br>使用mail组件进行发送邮件<br>检查是否安装mail：rpm -qa | grep mail<br>如果没安装就运行该命令：yum -y install mailx</li>
<li>发送邮件到QQ或163邮箱测试效果   <pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token builtin class-name">echo</span> <span class="token string">"content"</span> <span class="token operator">|</span> mail <span class="token parameter variable">-s</span> <span class="token string">"title"</span> xxxxxxx@163.com
<span class="token function">tail</span> <span class="token parameter variable">-f</span> /var/log/maillog 查看日志，成功提示 <span class="token number">250</span> Ok<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre></li>
<li>设置虚拟机hostname<pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">hostnamectl set-hostname mail.xxx.com<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre></li>
<li>在本地电脑添加域名DNS：vim &#x2F;etc&#x2F;hosts<br>添加一条记录指向虚拟机域名mail.xxx.com<br>ip mail.xxx.com</li>
</ol>
<h2 id="java-调用"><a href="#java-调用" class="headerlink" title="java 调用"></a>java 调用</h2><pre class="line-numbers language-java" data-language="java"><code class="language-java"><span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">SendJEmail</span> <span class="token punctuation">&#123;</span>
    <span class="token comment">/*
     * 拷贝代码直接将下面四个属性改成自己的就可以了
     * */</span>
    <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> smtphost <span class="token operator">=</span> <span class="token string">"mail.xxxx.com"</span><span class="token punctuation">;</span>  <span class="token comment">// 发送邮件的服务商</span>
    <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> from <span class="token operator">=</span> <span class="token string">"test@xxx.com"</span><span class="token punctuation">;</span> 	    <span class="token comment">// smtp帐号</span>
    <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> username <span class="token operator">=</span> <span class="token string">"test@xxx.com"</span><span class="token punctuation">;</span> 	<span class="token comment">// smtp帐号</span>
    <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> password <span class="token operator">=</span> <span class="token string">"test密码"</span><span class="token punctuation">;</span> 	 <span class="token comment">// smtp用户的密码</span>

    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">boolean</span> <span class="token function">sendMail</span><span class="token punctuation">(</span><span class="token class-name">String</span> <span class="token keyword">to</span><span class="token punctuation">,</span> <span class="token class-name">String</span> emailMsg<span class="token punctuation">)</span> <span class="token punctuation">&#123;</span>

        <span class="token comment">//定义Properties对象,设置环境信息</span>
        <span class="token class-name">Properties</span> props <span class="token operator">=</span> <span class="token class-name">System</span><span class="token punctuation">.</span><span class="token function">getProperties</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">//设置邮件服务器的地址</span>
        props<span class="token punctuation">.</span><span class="token function">setProperty</span><span class="token punctuation">(</span><span class="token string">"mail.smtp.host"</span><span class="token punctuation">,</span> smtphost<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 指定的smtp服务器</span>
        props<span class="token punctuation">.</span><span class="token function">setProperty</span><span class="token punctuation">(</span><span class="token string">"mail.smtp.auth"</span><span class="token punctuation">,</span> <span class="token string">"true"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        props<span class="token punctuation">.</span><span class="token function">setProperty</span><span class="token punctuation">(</span><span class="token string">"mail.transport.protocol"</span><span class="token punctuation">,</span> <span class="token string">"smtp"</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//设置发送邮件使用的协议</span>
        <span class="token comment">//创建Session对象,session对象表示整个邮件的环境信息</span>
        <span class="token class-name">Session</span> session <span class="token operator">=</span> <span class="token class-name">Session</span><span class="token punctuation">.</span><span class="token function">getInstance</span><span class="token punctuation">(</span>props<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//设置输出调试信息</span>
        session<span class="token punctuation">.</span><span class="token function">setDebug</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">try</span> <span class="token punctuation">&#123;</span>
            <span class="token comment">//Message的实例对象表示一封电子邮件</span>
            <span class="token class-name">MimeMessage</span> message <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">MimeMessage</span><span class="token punctuation">(</span>session<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">//设置发件人的地址</span>
            message<span class="token punctuation">.</span><span class="token function">setFrom</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">InternetAddress</span><span class="token punctuation">(</span>from<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">//设置主题</span>
            message<span class="token punctuation">.</span><span class="token function">setSubject</span><span class="token punctuation">(</span><span class="token string">"SMTP"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">//设置邮件的文本内容</span>
            message<span class="token punctuation">.</span><span class="token function">setContent</span><span class="token punctuation">(</span><span class="token punctuation">(</span>emailMsg<span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token string">"text/html;charset=utf-8"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

            <span class="token comment">//设置附件</span>
            <span class="token comment">//message.setDataHandler(dh);</span>
            <span class="token comment">//添加附件部分</span>
            <span class="token comment">//邮件内容部分1---文本内容</span>
            <span class="token class-name">MimeBodyPart</span> body0 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">MimeBodyPart</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//邮件中的文字部分</span>
            body0<span class="token punctuation">.</span><span class="token function">setContent</span><span class="token punctuation">(</span><span class="token string">"这是两张&lt;font color='red'>图片&lt;/font>...."</span><span class="token punctuation">,</span><span class="token string">"text/html;charset=utf-8"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

            <span class="token comment">//邮件内容部分2---附件1</span>
            <span class="token class-name">MimeBodyPart</span> body1 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">MimeBodyPart</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> 
            body1<span class="token punctuation">.</span><span class="token function">setDataHandler</span><span class="token punctuation">(</span> <span class="token keyword">new</span> <span class="token class-name">DataHandler</span><span class="token punctuation">(</span> <span class="token keyword">new</span> <span class="token class-name">FileDataSource</span><span class="token punctuation">(</span><span class="token string">"/Users/chengcheng/Documents/noLine100.json"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">//./代表项目根目录下</span>
            body1<span class="token punctuation">.</span><span class="token function">setFileName</span><span class="token punctuation">(</span> <span class="token class-name">MimeUtility</span><span class="token punctuation">.</span><span class="token function">encodeText</span><span class="token punctuation">(</span><span class="token string">"无换行100.json"</span><span class="token punctuation">)</span> <span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">//中文附件名，解决乱码</span>

            <span class="token comment">//邮件内容部分3---附件2</span>
            <span class="token class-name">MimeBodyPart</span> body2 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">MimeBodyPart</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> 
            body2<span class="token punctuation">.</span><span class="token function">setDataHandler</span><span class="token punctuation">(</span> <span class="token keyword">new</span> <span class="token class-name">DataHandler</span><span class="token punctuation">(</span> <span class="token keyword">new</span> <span class="token class-name">FileDataSource</span><span class="token punctuation">(</span><span class="token string">"/Users/chengcheng/Documents/noLine1000.json"</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//./代表项目根目录下</span>
            body2<span class="token punctuation">.</span><span class="token function">setFileName</span><span class="token punctuation">(</span> <span class="token class-name">MimeUtility</span><span class="token punctuation">.</span><span class="token function">encodeText</span><span class="token punctuation">(</span><span class="token string">"无换行1000.json"</span><span class="token punctuation">)</span> <span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">//中文附件名，解决乱码</span>
            <span class="token comment">//把上面的3部分组装在一起，设置到msg中</span>
            <span class="token class-name">MimeMultipart</span> mimeMultipart <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">MimeMultipart</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            mimeMultipart<span class="token punctuation">.</span><span class="token function">addBodyPart</span><span class="token punctuation">(</span>body0<span class="token punctuation">)</span><span class="token punctuation">;</span>
            mimeMultipart<span class="token punctuation">.</span><span class="token function">addBodyPart</span><span class="token punctuation">(</span>body1<span class="token punctuation">)</span><span class="token punctuation">;</span>
            mimeMultipart<span class="token punctuation">.</span><span class="token function">addBodyPart</span><span class="token punctuation">(</span>body2<span class="token punctuation">)</span><span class="token punctuation">;</span>
            message<span class="token punctuation">.</span><span class="token function">setContent</span><span class="token punctuation">(</span>mimeMultipart<span class="token punctuation">)</span><span class="token punctuation">;</span>

            <span class="token comment">//从session的环境中获取发送邮件的对象</span>
            <span class="token class-name">Transport</span> transport<span class="token operator">=</span>session<span class="token punctuation">.</span><span class="token function">getTransport</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">//连接邮件服务器</span>
            transport<span class="token punctuation">.</span><span class="token function">connect</span><span class="token punctuation">(</span>smtphost<span class="token punctuation">,</span><span class="token number">25</span><span class="token punctuation">,</span> username<span class="token punctuation">,</span> password<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">//设置收件人地址,并发送消息</span>
            transport<span class="token punctuation">.</span><span class="token function">sendMessage</span><span class="token punctuation">(</span>message<span class="token punctuation">,</span><span class="token keyword">new</span> <span class="token class-name">Address</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">&#123;</span><span class="token keyword">new</span> <span class="token class-name">InternetAddress</span><span class="token punctuation">(</span><span class="token keyword">to</span><span class="token punctuation">)</span><span class="token punctuation">&#125;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            transport<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
        <span class="token punctuation">&#125;</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span><span class="token class-name">MessagingException</span> e<span class="token punctuation">)</span> <span class="token punctuation">&#123;</span>
            e<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
        <span class="token punctuation">&#125;</span>
    <span class="token punctuation">&#125;</span>

    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span> <span class="token punctuation">&#123;</span>
        <span class="token class-name">String</span> email <span class="token operator">=</span> <span class="token string">"收件人邮箱"</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> html <span class="token operator">=</span> <span class="token string">"hello from java"</span><span class="token punctuation">;</span>
        <span class="token class-name">SendJEmail</span><span class="token punctuation">.</span><span class="token function">sendMail</span><span class="token punctuation">(</span>email<span class="token punctuation">,</span> html<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<p>发送成功</p>
<pre class="line-numbers language-java" data-language="java"><code class="language-java"><span class="token constant">MAIL</span> <span class="token constant">FROM</span><span class="token operator">:</span><span class="token operator">&lt;</span>test<span class="token annotation punctuation">@xxx.com</span><span class="token operator">></span>
<span class="token number">250</span> <span class="token number">2.1</span><span class="token number">.0</span> <span class="token class-name">Ok</span>
<span class="token constant">RCPT</span> <span class="token constant">TO</span><span class="token operator">:</span><span class="token operator">&lt;</span>收件人<span class="token annotation punctuation">@163.com</span><span class="token operator">></span>
<span class="token number">250</span> <span class="token number">2.1</span><span class="token number">.5</span> <span class="token class-name">Ok</span>
<span class="token constant">DEBUG</span> <span class="token constant">SMTP</span><span class="token operator">:</span> <span class="token class-name">Verified</span> <span class="token class-name">Addresses</span>
<span class="token constant">DEBUG</span> <span class="token constant">SMTP</span><span class="token operator">:</span>   收件人<span class="token annotation punctuation">@163.com</span>
<span class="token constant">DATA</span>
<span class="token number">354</span> <span class="token class-name">End</span> data <span class="token keyword">with</span> <span class="token generics"><span class="token punctuation">&lt;</span>CR<span class="token punctuation">></span></span><span class="token generics"><span class="token punctuation">&lt;</span>LF<span class="token punctuation">></span></span><span class="token punctuation">.</span><span class="token generics"><span class="token punctuation">&lt;</span>CR<span class="token punctuation">></span></span><span class="token generics"><span class="token punctuation">&lt;</span>LF<span class="token punctuation">></span></span>
<span class="token class-name">From</span><span class="token operator">:</span> test<span class="token annotation punctuation">@xxx.com</span>
<span class="token class-name">Message</span><span class="token operator">-</span><span class="token constant">ID</span><span class="token operator">:</span> <span class="token operator">&lt;</span><span class="token number">1650967483.0</span><span class="token number">.1667526783643</span><span class="token punctuation">.</span>JavaMail<span class="token punctuation">.</span>chengcheng<span class="token annotation punctuation">@chengchengdeAir</span><span class="token operator">></span>
<span class="token class-name">Subject</span><span class="token operator">:</span> <span class="token operator">=</span><span class="token operator">?</span><span class="token constant">UTF</span><span class="token operator">-</span><span class="token number">8</span><span class="token operator">?</span><span class="token class-name">B</span><span class="token operator">?</span><span class="token number">55</span>So5oi35r<span class="token operator">+</span><span class="token class-name">A5rS7</span><span class="token operator">?</span><span class="token operator">=</span>
<span class="token constant">MIME</span><span class="token operator">-</span><span class="token class-name">Version</span><span class="token operator">:</span> <span class="token number">1.0</span>
<span class="token class-name">Content</span><span class="token operator">-</span><span class="token class-name">Type</span><span class="token operator">:</span> text<span class="token operator">/</span>html<span class="token punctuation">;</span>charset<span class="token operator">=</span>utf<span class="token operator">-</span><span class="token number">8</span>
<span class="token class-name">Content</span><span class="token operator">-</span><span class="token class-name">Transfer</span><span class="token operator">-</span><span class="token class-name">Encoding</span><span class="token operator">:</span> <span class="token number">7</span>bit

hello from java
<span class="token punctuation">.</span>
<span class="token number">250</span> <span class="token number">2.0</span><span class="token number">.0</span> <span class="token class-name">Ok</span><span class="token operator">:</span> queued as <span class="token number">813D</span><span class="token number">42217</span><span class="token constant">C5D</span>
<span class="token constant">QUIT</span>
<span class="token number">221</span> <span class="token number">2.0</span><span class="token number">.0</span> <span class="token class-name">Bye</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/shiqing/about" rel="external nofollow noreferrer">ShiQing</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://shiqing.gitee.io/shiqing/2022/12/02/centos-xu-ni-ji/">https://shiqing.gitee.io/shiqing/2022/12/02/centos-xu-ni-ji/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/shiqing/about" target="_blank">ShiQing</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/shiqing/tags/Linux/">
                                    <span class="chip bg-color">Linux</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/shiqing/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/shiqing/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/shiqing/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/shiqing/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/shiqing/2022/12/02/swagger-pei-zhi/">
                    <div class="card-image">
                        
                        
                        <img src="/shiqing/medias/featureimages/3.jpg" class="responsive-img" alt="Swagger配置">
                        
                        <span class="card-title">Swagger配置</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2022-12-02
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            ShiQing
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/shiqing/tags/Java/">
                        <span class="chip bg-color">Java</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/shiqing/2022/12/02/react/">
                    <div class="card-image">
                        
                        
                        <img src="/shiqing/medias/featureimages/15.jpg" class="responsive-img" alt="React">
                        
                        <span class="card-title">React</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2022-12-02
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            ShiQing
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/shiqing/tags/Javascript/">
                        <span class="chip bg-color">Javascript</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/shiqing/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/shiqing/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/shiqing/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/shiqing/libs/codeBlock/codeShrink.js"></script>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/shiqing/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




        <footer class="page-footer bg-color">
    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2019-2024</span>
            
            <span id="year">2019</span>
            <a href="/shiqing/about" target="_blank">ShiQing</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/blinkfox" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:2528393970@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>



    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=2528393970" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 2528393970" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/shiqing/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


        <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/shiqing/search.xml', 'searchInput', 'searchResult');
});
</script>

        <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


        <script src="/shiqing/libs/materialize/materialize.min.js"></script>
        <script src="/shiqing/libs/masonry/masonry.pkgd.min.js"></script>
        <script src="/shiqing/libs/aos/aos.js"></script>
        <script src="/shiqing/libs/scrollprogress/scrollProgress.min.js"></script>
        <script src="/shiqing/libs/lightGallery/js/lightgallery-all.min.js"></script>
        <script src="/shiqing/js/matery.js"></script>

        <!-- Baidu Analytics -->

        <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

        
        <script src="/shiqing/libs/others/clicklove.js" async="async"></script>
        
        
        <script async src="/shiqing/libs/others/busuanzi.pure.mini.js"></script>
        

        <script type="text/javascript">
            var OriginTitile = document.title,
                st;
            document.addEventListener("visibilitychange", function () {
                document.hidden ? (document.title = "看不见我~看不见我~", clearTimeout(st)) : (document.title =
                    "(๑•̀ㅂ•́) ✧被发现了～", st = setTimeout(function () {
                        document.title = OriginTitile
                    }, 3e3))
            })
        </script>

        <!-- 背景樱花飘落特效 -->
        
            <script type="text/javascript">
                //只在桌面版网页启用特效
                var windowWidth = $(window).width();
                if (windowWidth > 768) {
                    document.write('<script type="text/javascript" src="/js/xuehuapiaoluo.js"><\/script>');
                }
            </script>
        

        

        


        
        

        

        

        
        <script src="/shiqing/libs/instantpage/instantpage.js" type="module"></script>
        

    </body>

</html>
